<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>音频编码设置</title>
<link rel="stylesheet" href="/bootstrap-3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/config.css">

<link rel="icon" href="favicon.png" type="image/png"/>

<script src="/script/jquery-1.10.2.js"></script>
<script src="/bootstrap-3.3.5/js/bootstrap.min.js"></script>

</head>

<body>

<div id="header">
<nav class="navbar navbar-default navbar-fixed-top">
	<div class="container">
	
	    <div class="navbar-header">
	        <img alt="Brand" src="/image/logo.png">
	    </div>
    	
	 	<ul class="nav navbar-nav">
	 		<li><a>高清编码器配置操作平台</a></li>
	 	</ul>
 	
	 	<ul class="nav navbar-nav navbar-right">
	      <li><a href="support.html">更多服务与支持</a></li>
	    </ul>
 	
	</div>
</nav>
</div>

<div class="container">
	<div class="page-header text-center">
		<h3>音频编码设置</h3>
	</div>
    <div class="panel panel-default">
	  <div class="panel-heading">音频编码设置</div>
	  <div class="panel-body">
	    <div class="form-horizontal">
			<div class="form-group">
				<label for="inputEmail3" class="col-sm-2 control-label">音频比特率</label>
				<div class="col-sm-5">
					<select class="form-control" id="select-rate">
						<option value="48000">48000</option>
						<option value="64000">64000</option>
						<option value="96000">96000</option>
						<option value="128000">128000</option>
						<option value="160000">160000</option>
						<option value="192000">192000</option>
						<option value="256000">256000</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label for="inputEmail3" class="col-sm-2 control-label">音频编码方式</label>
				<div class="col-sm-5">
					<select class="form-control" id="select-codec">
						<option value="AAC">AAC</option>
						<option value="G.711">G.711</option>
						<option value="mp3">MP3</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label for="inputEmail3" class="col-sm-2 control-label">音频重采样</label>
				<div class="col-sm-5">
					<select class="form-control" id="select-resample">
						<option value="48000">48000</option>
						<option value="44100">44100</option>
						<option value="32000">32000</option>
						<option value="16000">16000</option>
						<option value="8000">8000</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label for="inputEmail3" class="col-sm-2 control-label">音频数字增益</label>
				<div class="col-sm-5">
					<select class="form-control" id="select-gain">
						<option value="0">关闭</option>
						<option value="2">2倍</option>
						<option value="4">4倍</option>
						<option value="8">8倍</option>
					</select>
				</div>
			</div>
			
			<div class="form-group">
				<label for="inputEmail3" class="col-sm-2 control-label">音频输入模式</label>
				<div class="col-sm-5">
					<select class="form-control" id="select-input">
						<option value="digit">数字输入</option>
						<option value="analog">模拟输入</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label for="inputEmail3" class="col-sm-2 control-label">音频采样率检测</label>
				<div class="col-sm-5">
					<select class="form-control" id="select-check">
						<option value="0">禁止</option>
						<option value="1">断开流服务</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button class="btn btn-primary" onclick="setAudioParam()">设置</button>
				</div>
			</div>
			
		</div>
	  </div>
	</div>
</div>

<footer id="footer">
	<nav class="navbar navbar-default navbar-fixed-bottom">
	   <div class="center">
	      <ul class="nav navbar-nav">
	         <li><a href="index.html">状态显示</a></li>
	         <li><a href="network.html">网络设置</a></li>
	         <li><a href="master-video.html">主流编码设置</a></li>
	         <li><a href="sub-video.html">副流编码设置</a></li>
	         <li><a href="audio.html">音频编码设置</a></li>
	         <li><a href="system.html">系统设置</a></li>
	      </ul>
	   </div>
	   
	   	<div class="container center">
		<a href="#">高清编码器配置操作平台</a>
		</div>
	</nav>

</footer>


<script type="text/javascript">


function toEnable(b) {
	return b ? "enabled" : "disabled";
}

function fromEnable(text) {
	return text == "enabled";
}

$(document).ready(function() {
	$("#footer li:eq(4)").addClass("active");
	
	$.getJSON(getBaseUri() + '/api/audio', function(data) {
		var audio = data;
		
		$("#select-codec").val(audio.codec);
		$("#select-rate").val(audio.sampleRate);
		$("#select-resample").val(audio.resample);
		$("#select-gain").val(audio.gain);
		
		$("#select-input").get(0).selectedIndex = audio.inputMode;
		$("#select-check").val(audio.checkRate);
	});
	
});

function getBaseUri() {
	var baseUri="http://" + window.location.host;
	return baseUri;
}

function setAudioParam() {
	var audio = {
		codec: $("#select-codec").val(),
		sampleRate: $("#select-rate").val(),
		resample:$("#select-resample").val(),
		gain: $("#select-gain").val(),
		
		inputMode: $("#select-input").get(0).selectedIndex,
		checkRate: $("#select-check").val()
	};
	
	var content = JSON.stringify(audio);
	$.post(getBaseUri() + '/api/audio', content, function(data){
		alert("设置音频参数成功");
	});
}

</script>


</body>
</html>